// Hamburger Menu Toggle const hamburger = document.getElementById('hamburger'); const mobileMenu = document.getElementById('mobileMenu'); function toggleMenu() { hamburger.classList.toggle('active'); mobileMenu.classList.toggle('active'); document.body.style.overflow = mobileMenu.classList.contains('active') ? 'hidden' : ''; } hamburger.addEventListener('click', toggleMenu); hamburger.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') toggleMenu(); }); // Mobile Dropdown Toggle function toggleMobileDropdown(event, element) { event.preventDefault(); const parent = element.parentElement; parent.classList.toggle('open'); } // Close Mobile Menu function closeMobileMenu() { hamburger.classList.remove('active'); mobileMenu.classList.remove('active'); document.body.style.overflow = ''; } // #game sabit görünüm garantisi (function(){ const screenArea = document.getElementById('screenArea'); if (!screenArea) return; function fixGameView() { screenArea.style.height = "100%"; screenArea.style.transform = "none"; } fixGameView(); })(); // Smooth Scroll document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { const href = this.getAttribute('href'); if (!href || href === '#') return; e.preventDefault(); const target = document.querySelector(href); if (target) target.scrollIntoView({ behavior: 'smooth' }); }); }); // Header Scroll Effect - Transparan to Solid + Intro Split const introButtons = document.querySelectorAll('.intro-buttons .intro-btn'); const introSection = document.querySelector('.intro-section'); window.addEventListener('scroll', () => { const header = document.querySelector('.header'); const scrollY = window.scrollY; if (scrollY > 100) header.classList.add('scrolled'); else header.classList.remove('scrolled'); if (introButtons.length >= 2) { const introHeight = introSection.offsetHeight; const splitAmount = Math.min(scrollY * 0.5, 150); const opacity = Math.max(1 - (scrollY / introHeight) * 1.5, 0); introButtons[0].style.transform = `translateX(-${splitAmount}px)`; introButtons[1].style.transform = `translateX(${splitAmount}px)`; introButtons.forEach(btn => { btn.style.opacity = opacity; }); } }); // ✅ Gallery: tıkla-büyüt (Lightbox) const lightbox = document.getElementById('lightbox'); const lightboxImg = document.getElementById('lightboxImg'); const lightboxClose = document.getElementById('lightboxClose'); function openLightbox(src, alt) { lightboxImg.src = src; lightboxImg.alt = alt || 'Büyük görsel'; lightbox.classList.add('open'); lightbox.setAttribute('aria-hidden', 'false'); document.body.style.overflow = 'hidden'; } function closeLightbox() { lightbox.classList.remove('open'); lightbox.setAttribute('aria-hidden', 'true'); lightboxImg.src = ''; document.body.style.overflow = ''; } // Not: Bazı temalarda img üstünde overlay/pseudo-element olabiliyor. // Bu yüzden click'i hem .gallery-item hem de img üzerinden yakalıyoruz. document.querySelectorAll('.gallery-item').forEach(item => { item.addEventListener('click', (e) => { const img = item.querySelector('img'); if (!img) return; // Eğer bir link vs. varsa varsayılanı engelle if (e.cancelable) e.preventDefault(); openLightbox(img.currentSrc || img.src, img.alt); }); }); lightbox.addEventListener('click', (e) => { if (e.target === lightbox) closeLightbox(); }); lightboxClose.addEventListener('click', closeLightbox); window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && lightbox.classList.contains('open')) closeLightbox(); }); // ===== SCROLL İLE SAYFA YÜKLENMESİ ===== const revealObserverOptions = { threshold: 0.15, rootMargin: '0px 0px -70px 0px' }; let lastY_reveal = window.scrollY; const revealObserver = new IntersectionObserver((entries) => { const nowY = window.scrollY; const scrollingUp = nowY < lastY_reveal; lastY_reveal = nowY; entries.forEach(entry => { if (entry.isIntersecting) entry.target.classList.add('revealed'); if (!entry.isIntersecting && scrollingUp) entry.target.classList.remove('revealed'); }); }, revealObserverOptions); const revealElements = document.querySelectorAll(` .section-title, .reward-card, .edition-card, .feature-card, .gallery-item, .step-card, .about-content, .story-grid, .preregister-grid, .game-section-header, .cta-section, .notes-section `); revealElements.forEach((el, index) => { el.classList.add('reveal-element'); // ✅ feature-card altındaki delay tamamen kapalı if (el.classList.contains('feature-card')) { el.style.transitionDelay = '0s'; } else { el.style.transitionDelay = (index % 4) * 0.1 + 's'; } revealObserver.observe(el); }); // Sayfa açılır açılmaz scroll'u kilitle document.body.classList.add("preloader-active"); const MIN_DURATION = 1500; // 2.5 saniye const startTime = Date.now(); window.addEventListener("load", () => { const elapsed = Date.now() - startTime; const remaining = Math.max(0, MIN_DURATION - elapsed); setTimeout(() => { const preloader = document.getElementById("preloader"); if (!preloader) return; preloader.classList.add("hide"); document.body.classList.remove("preloader-active"); setTimeout(() => preloader.remove(), 300); }, remaining); }); (function(){ const el = document.getElementById("waveFloat"); if(!el) return; let lastY = window.scrollY; let ticking = false; const showAt = 120; // kaç px sonra görünmeye başlasın const hideAtTop = 30; // en üstte gizle function update(){ const y = window.scrollY; const goingDown = y > lastY; lastY = y; // En üstte gizle if (y <= hideAtTop){ el.classList.remove("is-visible"); ticking = false; return; } // Aşağı indikçe "gelsin" if (y > showAt && goingDown){ el.classList.add("is-visible"); } // Yukarı çıkarken ister gizle ister dursun: // Yukarı çıkınca kalsın istiyorsan bu satırı kaldır. if (!goingDown && y < showAt){ el.classList.remove("is-visible"); } ticking = false; } window.addEventListener("scroll", () => { if (!ticking){ ticking = true; requestAnimationFrame(update); } }, { passive:true }); // Sayfa ortasından açıldıysa (refresh / anchor) doğru state update(); })();